package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.HotSetmeal;
import com.itheima.pojo.Order;
import com.itheima.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {

    /**
     * 分页查询预约信息
     * @param queryString
     * @return
     */
    Page<OrderVO> pageQuery(String queryString);

    /**
     * 修改预约信息
     * @param order
     */
    void update(Order order);


    /**
     * 统计预约数量
     * @return
     */
    @Select("select s.name as name,count(o.id) as value from t_order o,t_setmeal s where o.setmeal_id = s.id group by s.id")
    List<Map<String, Object>> findSetmealCount();

    /**
     * 根据日期统计到诊人数
     * @param beginDate
     * @param endDate
     * @return
     */
    Integer getMemberCountByDate(LocalDate beginDate, LocalDate endDate);

    /**
     * 获取热门套餐
     * @return
     */
    @Select("select s.name as name,count(o.id) as setmealCount from t_order o,t_setmeal s where o.setmeal_id = s.id group by s.id order by setmealCount desc limit 4")
    List<HotSetmeal> getHotSetmeal();

    /**
     * 统计预约数量
     * @return
     */
    Integer findOrderCountByDate(LocalDate beginDate, LocalDate endDate);


}
